import javafx.util.Pair;
import jdk.nashorn.internal.runtime.regexp.joni.exception.SyntaxException;

import javax.crypto.interfaces.PBEKey;
import java.util.*;

/**
 * @author yu
 * @date 2025年04月19日 12:18
 */

public class _01 {
    static class Pair{
        int value,index;
        Pair(int value, int index){
            this.value =value;
            this.index = index;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while (T-- >0){
            int n = scanner.nextInt();
            Pair[] arr = new Pair[n];
            for (int i = 0; i < n; i++) {
                int val = scanner.nextInt();
                arr[i] = new Pair(val,i);//值+下标
            }
            Arrays.sort(arr,Comparator.comparing(p -> p.value));

            int forward = 0,backward =0;
            for (int i = 1; i < n; i++) {
                if(arr[i].index > arr[i-1].index){
                    forward++;
                }else {
                    backward++;
                }
            }
            System.out.println(forward + " " + backward);
        }
        scanner.close();
    }
}
